<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>

<html>

 <head>
    
    <title>物料类型管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>

		<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/yd/basic/matertypeUpdate";
		var basic_WUrl="yd/basic/matertypeUpdate";
		var basic_Title="添加功能";
		var show_Width=520;
		var show_Hight=300;
		var bmID = null;
		function createSearch(){
			init(1,8,'140,140,140,140','25%');

			//第一行的数据
			addCommon(0,0,"lable","类型名称：");
			addCommon(0,1,"txtlike","name");
			addCommon(0,2,"lable","编码：");
			addCommon(0,3,"txtlike","code");
		}
		function searchAP(){	
			if(bmID == null){
				multipleSearch("#table1",true,"",basic_Url+"/list.do");
			}else{
				multipleSearch("#table1",true,"",basic_Url+"/list.do?bmID="+bmID);
			}		
		}
// 		 function getSelected(){
// 			 var grid = $("#table1").ligerGetGridManager(); 
// 				var rows = grid.getCheckedRows();
// 				if(rows.length==0){
// 					alert("请选择一行数据!");
// 					return null;
// 				}else{
// 					return rows[0];
// 				}
// 			}
		 
// 		 $(function(){
// 			//创建JQGRID表格
// 				var grid = $("#table1").ligerGrid({
// 			        columns: [
// 			                  { display: '材料类型名称', name: 'name', width: 120 },
// 			                  { display: '材料类型编码', name: 'code', width: 120 },
// 			                  { display: '父类型名称', name: 'parentname', width: 120},
// 			                  { display: '创建人', name: 'dcruser', width: 120},
// 			                  { display: '创建时间', name: 'dctime', width: 120,
// 			                	  render: function (item){
// 			                		  var cdate=new Date(item.dctime);
// 			                		  return formatDate(cdate,"yyyy-MM-dd HH:mm:ss")
// 			                	  }
// 			                  },
// 			                  { display: '是否可用', name: 'useStatus', width: 100,
// 			                	  render: function (item){               		 
// 			                		  var useStatus=item.useStatus;
// 			                		  if(useStatus=="0"){
// 			                			  return "正常";
// 			                		  }
// 			                		  if(useStatus=="1"){
// 			                			  return "锁定";
// 			                		  }
// 			                	  }},
// 			                  { display: '备注', name: 'remark', width: 120 }
// 			                      ],  usePager: true,pageSize:30,
// 			                      url : basic_Url+"/list.do",
// 			                      width: '100%', height: '98%', checkbox: true,rownumbers:true,           
// 			                      onDblClickRow : function (data, rowindex, rowobj){
// 			                          edit(data);
// 			                       }
// 			                  });
// 				$("#pageloading").hide();
// 		 });
function gettreeData() 
		 {    
			var manager = null;
			manager = $("#tree1").ligerGetTreeManager(); 
			manager.clear();
	        manager.loadData(null, basic_Url+'/tree.do');
	        manager.collapseAll();
		 }
		
		jQuery(document).ready(function() {
			//创建JQGRID表格
			var grid = $("#table1").ligerGrid({
		        columns: [
		                      { display: '物料类型名称', name: 'name', width: 120 },
			                  { display: '物料类型编码', name: 'code', width: 120 },
			                  { display: '父类型名称', name: 'parentname', width: 120},
			                  { display: '创建人', name: 'dcruser', width: 120},
			                  { display: '创建时间', name: 'dctime', width: 120,
			                	  render: function (item){
			                		  var cdate=new Date(item.dctime);
			                		  return formatDate(cdate,"yyyy-MM-dd HH:mm:ss")
			                	  }
			                  },
			                  { display: '是否可用', name: 'useStatus', width: 100,
			                	  render: function (item){               		 
			                		  var useStatus=item.useStatus;
			                		  if(useStatus=="0"){
			                			  return "正常";
			                		  }
			                		  if(useStatus=="1"){
			                			  return "锁定";
			                		  }
			                	  }},
			                  { display: '代码', name: 'remark', width: 120 }
		                      ],  usePager: true,pageSize:15,pageSizeOptions :[15,25,35],
		                      url : basic_Url+"/list.do",enabledSort:false,
		                      width: "100%", height:"100%", checkbox: true,      
		                      onDblClickRow : function (data, rowindex, rowobj){
		                    	  edititem(data);
		                       },
		                      toolbar: { items: [
												  { text: '增加类型', click: additem, icon: 'add' },
		                                          { text: '修改', click: getSelected, icon: 'modify' },
		                                          { line: true },
		                                          { text: '删除', click: del, img: '../../../js/ligerUI/skins/icons/delete.gif' }
		                                          ]
		                                          }
		                  });
			$("#pageloading").hide();
			
			
			$("#layout1").ligerLayout({ leftWidth: 200,height: '100%',heightDiff:-24,space:4});
			var actionNodeID=null;
			 
			
			$("#tree1").ligerTree({  
				 url: basic_Url+'/tree.do',
				 nodeWidth: 115,
				 checkbox: false,
		         slide: false,
		         onClick:function(node){
		        	 actionNodeID = node.data.id;
		        	 multipleSearch("#table1",true,"",basic_Url+"/list.do?ID="+node.data.id);
		         }
		     });
			
			 
			 //添加物料
			 function additem(){
				 if(actionNodeID == null || actionNodeID.length<=0){
					 $.dialog.alert("请选择需要添加的类型!");
					 return false;
				 }
					var url = "yd/basic/matertypeUpdate/operate/add/"+actionNodeID+".do";
					ShowIframeDialog("operate","添加物料",url,320,300);
			 }
			 
			//修改物料
			 function edititem(data){
					var url = "yd/basic/matertypeUpdate/operate/edit/"+data.id+".do";
					ShowIframeDialog("operate","修改物料",url,320,300);
			 }
			 
			//修改物料
			 function getSelected(){
				 var grid = $("#table1").ligerGetGridManager(); 
					var rows = grid.getCheckedRows();
					var data =grid.getSelectedRow();
					if(rows.length==0){
						$.dialog.alert("请选择一行数据!");
						return false;
					}else{
						edititem(data);
					}
			}
			 
		});
	</script>
  </head>
<!-- <body onLoad="createSearch()"> -->
<!--    <div id="layout1"> -->
<!--           <div class="panelBar"> -->
<!-- 	            <ul class="toolBar"> -->
<!-- 		           <li><a class="add" onclick="add()"> -->
<!-- 		           <span>添加</span></a></li> -->
<!-- 				   <li><a class="delete" onclick="del()"><span>删除</span></a></li> -->
<!--                </ul> -->
<!--           </div> -->
<!--           <div id="pageHeader" class="pageHeader"> -->
<!--                <div class="searchBar" id="multipleSearchDialog"> -->
<!-- 	                <table class="table" width="100%" id="searchHeader" >   -->
<!--                         <tbody id="newbody"> -->
<!--                         </tbody> -->
<!--  	                </table> -->
<!--                     <div class="subBar"> -->
<!-- 			             <ul> -->
<!-- 				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li> -->
<!-- 				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li> -->
<!-- 			             </ul> -->
<!-- 	                </div> -->
<!--                </div> -->
<!--           </div> -->
<!--       </div> -->
<!--       <div position="center" id="table1"> -->
<!--       </div> -->
<!--       <div class="clear"></div> -->
<!--    </div> -->
 
<!-- </body> -->
<body style="padding:10px" onLoad="createSearch()">  
       <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      <div id="layout1">
            <div position="left" title="物料分类">
            <div style="width:100%; height:380px; float:left;overflow:scroll;  ">
   				 <ul id="tree1"></ul>
    		</div> 
            </div>
            <div position="center" title="物料类型列表" id="table1">
            
            </div>  
        </div> 
    </body>
</html>